﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;

namespace Splittergame
{
    class Shockwave
    {     
        private Texture2D shockwaveTexture;
        private Vector2 shockwavePosition;
        private Vector2 origin;
        private float scale;
        private float fade = 0.3f;

        public Shockwave(Vector2 startPosition)
        {

            shockwavePosition = startPosition;
            scale = 0.1f;
        }

        internal void LoadContent(ContentManager content) 
        {
        
            shockwaveTexture = content.Load<Texture2D>("Shockwave");
            origin = new Vector2(shockwaveTexture.Width / 2.0f, shockwaveTexture.Height / 2.0f);
        }

        internal void Update(GameTime gameTime)
        {
            
            float ElapsedTime = (float)gameTime.TotalGameTime.TotalSeconds;
            scale *= 1.1f;
            fade -= (float)gameTime.ElapsedGameTime.TotalSeconds/2;
        }

        internal void Draw(SpriteBatch spriteBatch, Camera camera)
        {
            Color color = new Color(fade, fade, fade, fade);

            Rectangle ShockwaveRect = camera.getVisualRect(shockwavePosition.X, shockwavePosition.Y, 0.1f);
            spriteBatch.Draw(shockwaveTexture, camera.GetVisual(shockwavePosition), null, color, 0, origin, scale, SpriteEffects.None, 0);
        }
    }
}
